const app = getApp();
import { getCommission } from '../../utils/requestApi.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: app.data.imgurl,
    integral: '8800，0',  //
    activeItem: '1',
    page: 1,
    comData: '',
    listData:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.initData();
  },

  onShow: function (){
    
  },
   
  //选择tab
  selectTab:function(e){
    this.setData({
      activeItem: e.target.dataset.index
    })
  },

  initData(){
    let { page, listData } = this.data;
    wx.showLoading({ title: '加载中...' })
    getCommission({
      pageIndex: page,
      pageSize: 10
    }).then(res =>{
      wx.hideLoading();
      if (res.data.Status == 'Success'){
        this.setData({ comData: res.data.Result })
        if (res.data.Result.SplittinDrawsList && res.data.Result.SplittinDrawsList.length != 0) {
          listData = [...listData, ...res.data.Result.SplittinDrawsList]
          this.setData({ listData,  page: page + 1 })
        }
      }
    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.initData();    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }  

})